<%@ include file="/taglibs.jsp"%>
<jsp:directive.page import="java.util.Random"/>
<jsp:directive.page import="java.util.Date"/>
<%if(session.getAttribute("randFormID") == null){
	Random gen = new Random(new Date().getTime());
	session.setAttribute("randFormID", gen.nextInt() + "");
}

%>


<title>Winter War Gaming Convention - User Form</title>

<c:choose>
	<c:when test="${userID == '0' || userID == '' || userID == null}">
		<p>Thank you for choosing to become a part of the Winter War Gaming Convention Online system!  Please fill out the information below so that we can have your records on hand for ease of processing and registration.</p>
	</c:when>
	<c:otherwise>
		<p>Thank you for being a part of the Winter War Gaming Convention Online system!  Please review the information below so that we can have your records on hand for ease of processing and registration.</p>
	</c:otherwise>
</c:choose>
<br>
<p><b>NOTE:</b> <i>Winter War Gaming Convention will <b>NEVER</b> give your information to any third parties.  Your information will reside only in our database accessible only by our registrar and staff.  We value and respect our participant's privacy, and take great strides to ensure that your personal information stays personal.</i></p>

<p>Please fill out your information</p>

<html:form action="/user" focus="user.firstName" onsubmit="return validateUserForm(this)">
	<input type="hidden" name="method" value="save"/>
	<input type="hidden" name="user.level" value="1"/>
	<input type="hidden" name="formID" value="<%=session.getAttribute("randFormID") %>"/>
	<html:hidden property="user.userID"/>
	<table>
		<tr>
			<th><bean:message key="user.firstName"/>: </th>
			<td><html:text property="user.firstName"/></td>
			<th><bean:message key="user.phoneNumber"/>: </th>
			<td><html:text property="user.phoneNumber"/></td>
		</tr>
		<tr>
			<th><bean:message key="user.lastName"/>: </th>
			<td><html:text property="user.lastName"/></td>
			<th><bean:message key="user.email"/>: </th>
			<td><html:text property="user.email"/></td>
		</tr>
		<tr>
			<th><bean:message key="user.address1"/>: </th>
			<td><html:text property="user.address1"/></td>
		</tr>
		<tr>
			<th><bean:message key="user.address2"/>: </th>
			<td><html:text property="user.address2"/></td>
		</tr>
		<tr>
			<th><bean:message key="user.city"/>: </th>
			<td><html:text property="user.city"/></td>
			<c:choose>
				<c:when test="${userID == '0' || userID == '' || userID == null}">
				<th><bean:message key="user.username"/>: </th>
				<td><html:text property="user.username"/></td>
				</c:when>
				<c:otherwise>
					<td><html:hidden property="user.username"/></td>
					<td></td>
				</c:otherwise>
			</c:choose>
		</tr>
		<tr>
			<th><bean:message key="user.state"/>: </th>
			<td><html:text property="user.state"/></td>
			<th><bean:message key="user.password"/>: </th>
			<td><html:password property="user.password"/></td>
		</tr>
		<tr>
			<th><bean:message key="user.zipCode"/>: </th>
			<td><html:text property="user.zipCode"/></td>
			<th><bean:message key="user.passwordConfirm"/>: </th>
			<td><input type="password" name="user.passwordConfirm"/></td>
		</tr>
		<tr>
			<td></td>
			<td></td>
			<td><html:submit styleClass="button">Save</html:submit></td>
			<td>
			</td>
		</tr>		
	</table>
</html:form>
<c:choose>
	<c:when test="${user != null}">
		<h2>Submitted Events</h2>
		<c:forEach var="event" items="${user.submittedEvents}">
			<c:choose>
				<c:when test="${event.conID == conID }">
					${event.eventName } -- <c:choose><c:when test="${event.status == 1 }">Submitted <a href="event.do?method=edit&conID=${conID }&eventID=${event.eventID }&userID=${user.userID }">(Edit...)</a></c:when><c:when test="${event.status == 2 }">In Review</c:when><c:when test="${event.status == 3 }">Approved (${event.reservedSeats} / ${event.totalSeats})</c:when><c:when test="${event.status == 4 }">Rejected</c:when></c:choose><br>
				</c:when>
			</c:choose>
		</c:forEach>
		<h2>Registration Status</h2>
		<c:forEach var="reg" items="${user.registrations}">
			${reg.conName } -- <c:choose><c:when test="${reg.status == 1 }">Submitted</c:when><c:when test="${reg.status == 2 }">In Review</c:when><c:when test="${reg.status == 3 }">Approved</c:when><c:when test="${reg.status == 4 }">Rejected</c:when></c:choose> (Refference #: ${reg.regID }) <a href="/registration.do?method=view&conID=${reg.conID }&registrationID=${reg.regID }">View Details...</a><br>
		</c:forEach>
	</c:when>
</c:choose>
<html:javascript formName="userForm"/>